﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;

namespace Lilium.UI.Forms
{
	public sealed class MenuItemAdapter: IMenuItemAdapter
	{
		public MenuItemAdapter(MenuItem menuItem)
		{
			if (menuItem == null) throw new ArgumentNullException("menuItem");

			m_MenuItem = menuItem;
			menuItem.Click += MenuItem_Click;
		}

		#region IMenuItemAdapter Members

		#region public bool Checked

		public bool Checked
		{
			[DebuggerNonUserCodeAttribute]
			get
			{
				return MenuItem.Checked;
			}
			[DebuggerNonUserCodeAttribute]
			set
			{
				MenuItem.Checked = value;
			}
		}

		#endregion

		#region public event EventHandler<EventArgs> Click

		public event EventHandler<EventArgs> Click;

		private void MenuItem_Click(object sender, EventArgs e)
		{
			var handler = Click;
			if (handler != null)
				handler(this, e);
		}

		#endregion

		#endregion

		#region private MenuItem MenuItem

		private readonly MenuItem m_MenuItem;

		private MenuItem MenuItem
		{
			[DebuggerNonUserCodeAttribute]
			get
			{
				return m_MenuItem;
			}
		}

		#endregion
	}
}
